package com.queen.restaurant.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.queen.restaurant.dao.RestaurantDao;
import com.queen.restaurant.domain.Restaurant;

@Service
public class RestaurantService {

	@Autowired
	private RestaurantDao restaurantDao;

	//新增餐厅
	public void createRestaurant(Restaurant restaurant){
		restaurantDao.save(restaurant);
	}
	//餐厅登陆
	public Restaurant restaurantLogin(String restaurantName, String password){
		Restaurant restaurant = null;
		List<Restaurant> restaurantList = restaurantDao.findRestaurantByNameAndPasswd(restaurantName, password);
		if (restaurantList.size() > 0) {
			restaurant = restaurantList.get(0);
		}
		return restaurant;
	}
	//修改餐厅信息
	public void updateRestaurant(Restaurant restaurant){
		restaurantDao.update(restaurant);
	}
	public Restaurant getRestaurantById(String restaurantId){
		return restaurantDao.get(restaurantId);
	}
}
